package com.zz.parkingsystem.controller.user;

import com.zz.parkingsystem.entity.OrderItem;
import com.zz.parkingsystem.service.OrderItemService;
import com.zz.parkingsystem.service.OrderService;
import com.zz.parkingsystem.util.Result;
import com.zz.parkingsystem.util.ResultGenerator;
import com.zz.parkingsystem.vo.ShowVO;
import io.swagger.annotations.Api;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

@ResponseBody
@Controller
@RequestMapping("/show")
@Api(value = "",tags = "模板消息和订单缴费接口")
public class ShowController {
    @Autowired
    private OrderItemService orderItemService;
    //通过用户id查模板消息和订单缴费中的内容，确定其中的功能,封装成vo返回
    @GetMapping("show/{userId}/{state}")
    public Result show(@PathVariable Integer userId,@PathVariable Integer state){

        List<ShowVO> listShowVO = new ArrayList<ShowVO>();
        List<OrderItem> listOrder = orderItemService.selAllOrderItemByUserId(userId);
        Iterator<OrderItem> iterator = listOrder.iterator();
        if(state==4|| state==5 || state==6){

        }
        while (iterator.hasNext()){
            OrderItem orderItem = iterator.next();
            ShowVO show = orderItemService.show(orderItem.getOiNo());
            if(show.getState()==state){
                listShowVO.add(show);
            }
        }
        return ResultGenerator.genSuccessResult(listShowVO);
    }
}
